﻿
var teamlist = {
    gridDefine: {
        toolbar: { items: [{ text: lang.add, click: function () { openPage("teamedit", "", "", lang.add_new_workgroup); }, icon: 'add'}] },
        columns: [
            { display: lang.Workgroup_name, name: 'TEAM_NAME', minWidth: 200 },
            { display: lang.Project_undertaking_unit, name: 'ROLES_ID', minWidth: 150 },
            { display: lang.project_leader, name: 'TEAM_LEADER', minWidth: 75 },
            { display: lang.Project_level , name: 'PRO_LEVEL_STR', minWidth: 140 },
            { display: lang.zone_state, name: 'TEAM_STS', minWidth: 70, render: LinkTEAM_STS },
            { display: lang.Project_state, name: 'PRO_STS', minWidth: 102, render: LinkPRO_STS },
            { display: lang.Start_date, name: 'START_DATE', minWidth: 70, render: LinkTEAM_STAR_DATE },
            { display: lang.End_date, name: 'END_DATE', minWidth: 70, render: LinkTEAM_END_DATE },

            { display:lang.operation, name: 'HEL_CONTR', minWidth: 120, render: LinkOP, align: 'center' }
        ],
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "QueryTeamList"
    },
    init: function () {
        jsPageRender(this, true);
    },
    search: function () {
        jsPageSearch(this);
    }
}


function LinkOP(value, row, index) {
    var _str = 'teamid=' + row.TEAM_ID;
    return '<span style="padding-right:15px;padding-left:15px;"><a href="javascript:void(0)" onclick="openPage(\'teamedit\',\'' + _str + '\');">'+lang.edit+'</a></span><a href="javascript:void(0)" onclick="deleteteam(\'' + row.TEAM_ID + '\',\'' + row.TEAM_NAME + '\');">'+lang.delete_+'</a> ';
}
function LinkTEAM_STS(value, row, index) {
    if (row.TEAM_STS == '1') { return lang.open; }
    else {
        return lang.close;
    }
}
function LinkTEAM_STAR_DATE(value, row, index) {
    var dates = (String)(row.START_DATE);
    dates = dates.substring(0, 10);
    return dates;
}
function LinkTEAM_END_DATE(value, row, index) {
    var dates = (String)(row.END_DATE);
    dates = dates.substring(0, 10);
    return dates;
}
function LinkPRO_STS(value, row, index) {
    if (row.PRO_STS == '1') { return lang.Have_been_accepted; }
    else {
        return lang.Have_no_accepted;
    }
}

//#region 删除
function deleteteam(teamid, teamname) {
    if (teamid == "17") {
        alert(lang.Cannot_delete_project);
    }
    else {
        $.extend($.messager.defaults, {
            ok: lang.ok,
            cancel: lang.cancel
        });
        $.confirm(lang.Are_you_sure_to_delete_the_current_team + "[" + teamname + "]", lang.Delete_project, function (b) {
            if (b) {
                $.ajaxHandler({
                    url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                    urlType: "DeleteTeamInfo",
                    model: function () { return teamid; },
                    success: function (data) {
                        $.alert(lang.Successfully_deleted, null, function () {
                            teamlist.search();
                        });
                    }
                });
            }
        });

    }
   
}